<template>
  <div class="common-layout">
    <TopNavBar />
    <div class="main-container">
      <!-- 默认展示第一个折叠菜单中的第一个子菜单 -->
      <el-menu
        class="menu"
        default-active="/user"
        router
        active-text-color="#ffd04b"
        background-color="#545c64"
        :default-openeds="treeData"
        text-color="#fff"
      >
        <TreeMenu :tree-data="treeData" />
      </el-menu>
      <div class="content">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import TopNavBar from "@/components/TopNavBar.vue";
import TreeMenu from "@/components/TreeMenu.vue";
import { onMounted, ref } from "vue";
import { resources } from "@/api/user";

const treeData = ref([]);
onMounted(() => {
  resources().then(res => {
    treeData.value = res.data;
    console.log("🚀 ~ treeData.value", treeData.value);
  });
});
</script>

<style lang="scss">
.main-container {
  width: 100vw;
  margin-top: -1px;
  height: calc(100vh - 60px);
  box-sizing: border-box;
  display: flex;
  .menu {
    width: 200px;
  }
  .content {
    flex: 1;
    padding: 10px 20px;
    overflow-y: auto;
  }
}
</style>
